<!-- 全部订单 -->
<template>
  <div class="all">
    <div class="item" v-for="item in list" :key="item.id">
      <div class="title">
        <span>订单编号：<span class="code">{{item.order_no}}</span></span>
        <span class="state">待付款</span>
      </div>
      <div class="goods" v-for="good in item.goodslist" :key="good.id">
        <div>
          <img :src="good.imgurl" alt="" />
        </div>
        <div class="name">
          <div>{{good.goods_name}}</div>
          <div>规格：{{good.goods_attr}}</div>
          <div>
            <span>￥{{good.goods_price}}</span>
            <span>x{{good.total_num}}</span>
          </div>
        </div>
      </div>
      <div class="caozuo">
        <div>实付款：<span>￥{{item.pay_price}}</span></div>
        <div class="btns">
          <van-button type="default" size="small" style="width: 2rem; border-radius: 10px" v-if="item.pay_status==0">
            取消订单</van-button>
          <van-button color="rgb(92,155,246)" type="info" size="small"
            style="width: 2rem; border-radius: 10px; margin-left: 10px" v-if="item.pay_status==0">立即支付</van-button>
        </div>
      </div>
    </div>

  </div>
</template>

<script>

import { orderList } from "../../../api/order";
export default {
  name: "",
  props: {
    data: {
      type: Object
    }
  },
  data() {
    return {
      list: []
    };
  },
  methods: {

    async getData() {
      let res = await orderList({ userid: localStorage.getItem("userid"), order_status: "2" });
      if (res.status == 200) {
        this.list = res.data;
      }
    }

  },
  computed: {},
  watch: {},
  created() {
    this.getData();
  },
  mounted() { },
};
</script>

<style lang="scss" scoped>
.all {
  width: 100%;

  .item {
    margin-bottom: 10px;

    .title {
      display: flex;
      justify-content: space-between;
      background-color: #fff;
      padding: 40px 30px;
      font-size: 28px;

      .code {
        font-weight: bold;
      }

      .state {
        color: #3e96e8;
      }
    }

    .goods {
      padding: 30px;
      display: flex;

      img {
        width: 200px;
        height: 180px;
      }

      .name {
        flex: 1;
        margin-left: 20px;
        font-size: 28px;
        display: flex;
        flex-direction: column;
        justify-content: space-around;

        > :first-child {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          /*将对象作为弹性伸缩盒子模型显示*/
          -webkit-line-clamp: 2;
          /*限制文本的行数，只显示2行*/
          -webkit-box-orient: vertical;
        }

        > :last-child {
          color: #3e96e8;
          font-size: 30px;
          font-weight: bold;
          display: flex;
          justify-content: space-between;
          align-items: center;
        }
      }
    }

    .caozuo {
      padding: 30px;
      background-color: #fff;
      font-size: 28px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      > :last-child>span {
        color: #3e96e8;
      }
    }
  }
}
</style>